package com.micangcaihang.micang.mvp.login.model;

import com.micangcaihang.common.baserx.RxSchedulers;
import com.micangcaihang.common.http.ApiResult;
import com.micangcaihang.common.http.RxHelper;
import com.micangcaihang.micang.entity.UserEntity;
import com.micangcaihang.micang.http.ApiService;
import com.micangcaihang.micang.mvp.login.contract.LoginContract;

import io.reactivex.Observable;

/**
 * <pre>
 *     author : Fandy
 *     e-mail : fandayongfly@gmail.com
 *     time   : 2017/7/30
 *     update : 2017/7/30
 *     desc   : 登录
 *     version: 1.0
 * </pre>
 */

public class LoginModel implements LoginContract.Model {

    /**
     * 加载用户数据
     *
     * @param usermane
     * @param password
     * @return
     */
    @Override
    public Observable<ApiResult<UserEntity>> getUserData(String usermane, String password) {
        return ApiService.<ApiResult<UserEntity>>user_logon(usermane, password)
                .compose(RxSchedulers.observableIoToMain())
                .compose(RxHelper.handleResult());
    }
}
